package com.ag.dgm.dao;

import java.util.StringTokenizer;

import org.apache.commons.logging.LogFactory;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.ag.hmk.dao.HmkUiltDAO;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.Log;

public class BaseDAOdgm extends HibernateDaoSupport{
	
	private static final Log log = LogFactory.getLog(BaseDAOdgm.class);
	
	public void queryHQLUpdate(String hql){
		System.out.println("这是queryHQLUpdate方法");
		log.debug("queryUpdate");
		Session session =null;
		Transaction tx = null;
		try {
			//String sql="delete from tb_msg where custom_id='"+cusID+"'";
			session = getHibernateTemplate().getSessionFactory().openSession();
			tx = session.beginTransaction();
			session.createQuery(hql).executeUpdate();
			tx.commit();
			session.close();
		} catch (RuntimeException re) {
			log.error("queryUpdate" ,re);
			if(tx.isActive()){
				tx.rollback();
			}
			throw re;
		}
	}
	
	
	public String[] strToArray(String str) {
		  StringTokenizer st = new StringTokenizer(str, ",");
		  String[] strArray = new String[st.countTokens()];
		  int strLeng = st.countTokens();
		  for (int i=0; i<strLeng; i++) {
		   strArray[i] = st.nextToken();
		  }
		  return strArray;
	}
}
